<!-- jinja -->
<!-- no-sidebar -->
<!-- no-header -->
<!-- no-breadcrumbs -->
<!-- no-cache -->
<!-- title: ERPNext Charts -->

{% extends "templates/web.html" %}

{% macro show_charts(label, charts, tab, show_user=True) %}
	{% if charts %}
		<div class="{{ tab }} row col-sm-12">
			<h2> {{ label }}</h2>
			<hr class="chart-list-header">

			{% for chart in charts %}
				<div class="chart-list-item col-sm-12">
					<a href="/chart?company={{ chart.name }}&forked={{ chart.forked }}&submitted={{ chart.submitted }}&owner={{ chart.owner }}">
						<div class="pull-right text-muted small" style="margin-top:8px">
							<span class="octicon octicon-star"></span>
							<span class="star-count">{{ chart.stars }}</span>
						</div>
						<div>
							<h4 class="chart-name">{{ chart.chart_of_accounts_name or chart.name }}</h4>
							{% if show_user and chart.submitted_by != "Administrator" %}
								<div class="small text-muted chart-list-item-desc">
										Submitted by {{ chart.submitted_by }}
								</div>
							{% endif %}
						</div>
					</a>
				</div>
			{% endfor %}
		</div>

	{% endif %}
{% endmacro %}

{% block page_content %}

<style>{% include "chart_of_accounts_builder/www/all_charts.css" %}</style>

<div class="row hero" style="padding-bottom: 90px; text-align: center">
    <div class="col-sm-12">
        <img class="erp-hero" src="assets/chart_of_accounts_builder/images/chart-of-accounts-builder.svg" style="width: 200px; margin-top: 30px;">
    </div>
    <div class="col-sm-12 hero-content">
        <h1>ERPNext Chart of Accounts</h1>
        <p>Help build Chart of Accounts for ERPNext</p>
        <a class="btn btn-primary" href="#charts">Select a Chart to Start</a>
        <p class="description new-chart">
			or create a new chart.
		</p>
    </div>
</div>

<div id="charts" style="padding-top:40px">

	<div class="chart-search">
		<form method="get" action="#charts">
			<select type="text" class="form-control" name="search" placeholder="Search by country" onchange="this.form.submit()">
				<option value="" disabled selected> Search by country </option>
				{% for d in country %}
					<option value = "{{ d }}"> {{ d }} </option>
				{% endfor %}
			</select>
		</form>
	</div>

	{% if frappe.user != "Guest" and my_charts %}
		<div class="checkbox show_all_charts" style="padding-top: 20px;">
			<label>
				<input type="checkbox" data-fieldname="show_all_charts" />
				Show All Charts
			</label>
		</div>
	{% else %}
		<div class="padding"></div>
	{% endif %}

	{% if frappe.form_dict.search %}
		<p>Filtered by "{{ frappe.form_dict.search }}". <a href="/">Clear</a></p>
	{% endif %}

	{{ show_charts("All Charts", all_charts, "tab1", show_user=True) }}
	{{ show_charts("My Charts", my_charts, "tab2") }}
</div>

<script>{% include "chart_of_accounts_builder/www/all_charts.js" %}</script>

{% endblock %}